﻿// $Id: SqlServerSettings.cs 65 2008-05-06 20:58:14Z nvivo $

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace DBLGen.Plugins.Import
{
    public class SqlServerSettings : PluginSettings
    {
        private string _host;
        private string _user;
        private string _password;
        private string _database;
        private bool _useWindowsAuthentication;

        public string Host
        {
            get
            {
                return _host;
            }
            set
            {
                _host = value;
            }
        }

        public string User
        {
            get
            {
                return _user;
            }
            set
            {
                _user = value;
            }
        }

        public string Password
        {
            get
            {
                return _password;
            }
            set
            {
                _password = value;
            }
        }

        public string Database
        {
            get
            {
                return _database;
            }
            set
            {
                _database = value;
            }
        }

        public bool UseWindowsAuthentication
        {
            get
            {
                return _useWindowsAuthentication;
            }
            set
            {
                _useWindowsAuthentication = value;
            }
        }

        protected override NameValueCollection SaveSettings()
        {
            NameValueCollection col = new NameValueCollection();

            col["host"] = Host;
            col["user"] = User;
            col["pass"] = Password;
            col["database"] = Database;
            col["useWindowsAuthentication"] = UseWindowsAuthentication.ToString();

            return col;
        }

        protected override void LoadSettings(NameValueCollection settings)
        {
            Host = settings["host"];
            User = settings["user"];
            Password = settings["pass"];
            Database = settings["database"];
            UseWindowsAuthentication = Convert.ToBoolean(settings["useWindowsAuthentication"]);
        }

        public override PluginSettings Clone()
        {
            SqlServerSettings settings = new SqlServerSettings();

            settings._database = _database;
            settings._host = _host;
            settings._user = _user;
            settings._password = _password;
            settings._useWindowsAuthentication = _useWindowsAuthentication;

            return settings;
        }
    }
}
